# 各种表单验证的限制条件
import re

from wtforms import ValidationError

# 强制验证用户的手机号
def phone_required(form,field):
    username=field.data
    pattern=r'^1[0-9]{10}$'
    if not re.search(pattern,username):
        raise ValidationError('请输入手机号码')
    return field